const path=require('path');
let CleanWebpackPlugin = require('clean-webpack-plugin');

module.exports={
  entry:'./src/index.js',
  output:{
    filename:'bundle.js',
    path:path.resolve('dist'),
    // filename:'vue-tips.js'
    libraryTarget:'umd',//输出规范，amd\cmd\commonjs
    library:'MyFetch'//输出
  },
  module:{
    rules: [
                {
                    test:/\.js$/,
                    use: 'babel-loader',
                    include: /src/,          // 只转化src目录下的js
                    exclude: /node_modules/  // 排除掉node_modules，优化打包速度
                }
            ]
  },
  plugins:[
    new CleanWebpackPlugin('dist'),
  ],
  devServer:{
    proxy: {
        '/api': {
            target: 'http://localhost:3000',
            changeOrigin: true,
            pathRewrite: {
                '^/api': 'http://localhost:3000/api'
                // '^/': ''
            }
      }
    }
  },
  mode:'development'
}
//
// proxy: {
//     '/proxy': {
//         target: 'http://your_api_server.com',
//         changeOrigin: true,
//         pathRewrite: {
//             '^/proxy': ''
//         }
//   }
